import router from '@/router';
import { Message, MessageBox } from 'element-ui'


export default function({ isSuccess, content, errorMessage, errorCode}) {
  return new Promise((resolve, reject) => {
    if (!isSuccess) {
      switch (errorCode) {
        case "account_login.name_or_pass_fail":
          MessageBox.alert('系统检测到您在58安居客的账号密码发生了修改，请修改最新的密码重新绑定后进行使用~', '', {
            confirmButtonText: '重新绑定账号',
            callback: action => {
              router.push({ name: "portManagement" });
            }
          });
          break;
        case "account_login.check_mobile":
          MessageBox.alert('系统检测到您在58安居客的账号需要短信验证，验证完即可使用~', '', {
            confirmButtonText: '立即验证',
            callback: action => {
              router.push({ name: "portManagement" });
            }
          });
          break;
      
        default:
          Message({ message: errorMessage || '服务异常！', type: 'error', duration: 5 * 1000 })

          break;
      }

      return reject()
    }

    resolve(content)
  })
}